package com.sieaf.exception;

import java.io.PrintStream;
import java.io.PrintWriter;


/**
 * DAO���쳣
 * 
 * @author qi
 * @since jdk1.5.12
 * @version 1.0
 * @date 2007-09-11
 * 
 * �����ʱ��:2007-09-11
 * �޸���:qi
 * ������:qi
 */
public class DataAccessException extends RuntimeException {
	//Ƕ���쳣
	private Throwable cause;
	
	/**
	 * ���캯��
	 */
	public DataAccessException() {
		super();
	}
	
	/**
	 * ���캯��
	 * @param msg	�쳣��Ϣ
	 */
	public DataAccessException(String msg) {
		super(msg);		
	}
	
	/**
	 *  ���캯��
	 * @param msg
	 * @param ex
	 */
	public DataAccessException(String msg, Throwable ex){
		super(msg);
		this.cause = ex;
	}
	
	/**
	 * ȡ��Ƕ���쳣
	 */
	public Throwable getCause(){
		return (this.cause == null ? this :this.cause);
	}
	
	/**
	 * ��ȡ�쳣��Ϣ
	 */
	public String getMessage(){			
		return super.getMessage();
	}
	
	/**
	 * �����쳣��ջ
	 */
	public void printStackTrace(PrintStream ps){
		if(getCause() == null){
			super.printStackTrace(ps);	        
		}else{    
			ps.println(this);    
			getCause().printStackTrace(ps);    
		}    
	}    
	
	/**
	 * �����쳣��ջ
	 */
	public void printStackTrace(PrintWriter pw){
		if(getCause() == null){    
			super.printStackTrace(pw);    
		}else{    
			pw.println(this);    
			getCause().printStackTrace(pw);    
		}
	}
	
	/**
	 * �����쳣��ջ
	 */
	public void printStackTrace(){
		printStackTrace(System.err);
	}
	

}
